import {ServicePrefixEnum} from "@/enums/commonEnum";
import {RequestEnum} from "@/enums/httpEnum";
import type {AxiosRequestConfig} from "axios";
import {defHttp} from "@/utils/http/axios";

export interface NotifyTemplateVO {
  id?: number
  name: string
  nickname: string
  code: string
  content: string
  type?: number
  params: string
  status: number
  remark: string
}

export interface NotifySendReqVO {
  userId: number | null
  templateCode: string
  templateParams: Map<String, Object>
}

const MODULAR = '/system/notify-template';

export const Api = {
  GetNotifyTemplatePage:{
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/page`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig,
  GetNotifyTemplate:{
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/get`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig,
  CreateNotifyTemplate:{
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/create`,
    method: RequestEnum.POST,
  } as AxiosRequestConfig,
  UpdateNotifyTemplate:{
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/update`,
    method: RequestEnum.PUT,
  } as AxiosRequestConfig,
  DeleteNotifyTemplate:{
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/delete`,
    method: RequestEnum.DELETE,
  } as AxiosRequestConfig,
  SendNotify:{
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/send-notify`,
    method: RequestEnum.POST,
  } as AxiosRequestConfig
}

// 查询站内信模板列表
export const getNotifyTemplatePage = (params) => {
  return defHttp.request({ ...Api.GetNotifyTemplatePage,params})
}

// 查询站内信模板详情
export const getNotifyTemplate = (id) => {
  let params = {id:id}
  return defHttp.request({ ...Api.GetNotifyTemplate,params})
}

// 新增站内信模板
export const createNotifyTemplate = (data) => {
  return defHttp.request({ ...Api.CreateNotifyTemplate,params:data})
}

// 修改站内信模板
export const updateNotifyTemplate = (data) => {
  return defHttp.request({ ...Api.UpdateNotifyTemplate,params:data})
}

// 删除站内信模板
export const deleteNotifyTemplate = (id) => {
  let params = {id:id}
  return defHttp.request({ ...Api.DeleteNotifyTemplate,params})
}

// 发送站内信
export const sendNotify = (data) => {
  return defHttp.request({ ...Api.SendNotify,params:data})
}